package algocasts;

import java.util.Random;

public class P140_ImplementRand10UsingRand7 {

    private final Random random = new Random();

    public int rand7() {
        return random.nextInt(7) + 1;
    }

    public int rand10() {
        int x = Integer.MAX_VALUE;
        while (x > 10)
            x = 7 * (rand7() - 1) + rand7();
        return x;
    }

    public int rand10_pt() {
        int x = Integer.MAX_VALUE;
        while (x > 40)
            x = 7 * (rand7() - 1) + rand7();
        return x % 10 + 1;
    }

    public static void main(String[] args) {

    }
}
